package com.woniuxy.riskmanage.controller;

import com.woniuxy.commons.annotation.RequirePerms;
import com.woniuxy.commons.entity.PageBean;
import com.woniuxy.commons.entity.RuleLog;
import com.woniuxy.commons.utils.ResponseResult;
import com.woniuxy.riskmanage.service.RuleLogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author author
 * @create 2021-11-13 16:30
 */
@RestController
@RequestMapping("/rules")
public class RuleLogController {
    @Resource
    private RuleLogService ruleLogService;

    @Resource
    private RuleLogService logService;


    @GetMapping("/getAllRuleLog")
    public ResponseResult<PageBean> getAllRuleLog(int pageIndex, int pageSize) {
        List<RuleLog> allRuleLog = ruleLogService.getAllRuleLog(pageIndex, pageSize);
//        List<com.woniuxy.Rule.log.RuleLog> allRuleLog = logService.getall(pageIndex, pageSize);
        int i = ruleLogService.selectRuleLogCount();
        PageBean pageBean = new PageBean();
        pageBean.setBeanList(allRuleLog);
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecord(i);
        ResponseResult responseResult = new ResponseResult();
        responseResult.setCode(200);
        responseResult.setMessage("查询成功");
        responseResult.setData(pageBean);
        return responseResult;

    }


    @RequirePerms("user:del")
    @DeleteMapping("/dellog/{logid}")
    public ResponseResult del(@PathVariable("logid") int logid) {
        ruleLogService.delRuleLog(logid);
        ResponseResult responseResult = new ResponseResult();
        responseResult.setMessage("删除成功");
        responseResult.setCode(200);
        return responseResult;

    }








}
